package com.cloud.alibaba.custom.event;

import com.alibaba.fastjson.JSON;
import com.cloud.yangfeiself.dto.ResResult;
import com.cloud.yangfeiself.event.DistributeEvent;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
public class EventHandler {

    @EventListener
    public void handlerApp(DistributeEvent distributeEvent){
        System.out.println("JSON.toJSONString(distributeEvent) = " + JSON.toJSONString(distributeEvent));
    }

    @RabbitListener(queues = "my_any_queue")
    @RabbitHandler
    public void handle(ResResult resResult){
        System.out.println("msg = " + resResult);
    }
}
